\hypertarget{class_semaphore}{\section{Semaphore类 参考}
\label{class_semaphore}\index{Semaphore@{Semaphore}}
}


信号量抽象类(基于\+P\+O\+S\+I\+X接口)  




{\ttfamily \#include $<$Semaphore.\+h$>$}

类 Semaphore 继承关系图\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{class_semaphore}
\end{center}
\end{figure}
\subsection*{Public 成员函数}
\begin{DoxyCompactItemize}
\item 
\hypertarget{class_semaphore_ae86f21d900fd315d6938b15f1d2a9104}{virtual sint32 {\bfseries open} (sint32 value=1)=0}\label{class_semaphore_ae86f21d900fd315d6938b15f1d2a9104}

\item 
\hypertarget{class_semaphore_ab2a2586eb333ba65704c93dc82a01534}{virtual sint32 {\bfseries close} ()=0}\label{class_semaphore_ab2a2586eb333ba65704c93dc82a01534}

\item 
sint32 \hyperlink{class_semaphore_acbb526dfd6fa98bc2068652f5a61c661}{wait} ()
\begin{DoxyCompactList}\small\item\em 等待信号量 \end{DoxyCompactList}\item 
sint32 \hyperlink{class_semaphore_a7cbb633dbb25fa8c95c2a640a8ed16a2}{try\+Wait} ()
\begin{DoxyCompactList}\small\item\em 尝试等待信号量 \end{DoxyCompactList}\item 
sint32 \hyperlink{class_semaphore_ae97c8e0073930baaf3d39259bd87606a}{post} ()
\begin{DoxyCompactList}\small\item\em 释放信号量 \end{DoxyCompactList}\item 
sint32 \hyperlink{class_semaphore_ac02e23031c9521649a5ff7618d03fb93}{get\+Value} (sint32 \&value)
\begin{DoxyCompactList}\small\item\em 获取信号量值 \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Protected 属性}
\begin{DoxyCompactItemize}
\item 
\hypertarget{class_semaphore_a6d28483c923c2aafebed053ccd77d301}{sem\+\_\+t {\bfseries m\+\_\+sem}}\label{class_semaphore_a6d28483c923c2aafebed053ccd77d301}

\end{DoxyCompactItemize}


\subsection{详细描述}
信号量抽象类(基于\+P\+O\+S\+I\+X接口) 

\subsection{成员函数说明}
\hypertarget{class_semaphore_ac02e23031c9521649a5ff7618d03fb93}{\index{Semaphore@{Semaphore}!get\+Value@{get\+Value}}
\index{get\+Value@{get\+Value}!Semaphore@{Semaphore}}
\subsubsection[{get\+Value}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Semaphore\+::get\+Value (
\begin{DoxyParamCaption}
\item[{sint32 \&}]{value}
\end{DoxyParamCaption}
)}}\label{class_semaphore_ac02e23031c9521649a5ff7618d03fb93}


获取信号量值 


\begin{DoxyParams}{参数}
{\em value} & 当前值 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回\+S\+T\+A\+T\+U\+S\+\_\+\+O\+K,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
当value$>$0说明有资源,=0无资源,$<$0表示有$\vert$value$\vert$个线程在等待资源 
\end{DoxyNote}
\hypertarget{class_semaphore_ae97c8e0073930baaf3d39259bd87606a}{\index{Semaphore@{Semaphore}!post@{post}}
\index{post@{post}!Semaphore@{Semaphore}}
\subsubsection[{post}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Semaphore\+::post (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{class_semaphore_ae97c8e0073930baaf3d39259bd87606a}


释放信号量 


\begin{DoxyParams}{参数}
{\em void} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回\+S\+T\+A\+T\+U\+S\+\_\+\+O\+K,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
使信号量值增加1,释放资源 
\end{DoxyNote}
\hypertarget{class_semaphore_a7cbb633dbb25fa8c95c2a640a8ed16a2}{\index{Semaphore@{Semaphore}!try\+Wait@{try\+Wait}}
\index{try\+Wait@{try\+Wait}!Semaphore@{Semaphore}}
\subsubsection[{try\+Wait}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Semaphore\+::try\+Wait (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{class_semaphore_a7cbb633dbb25fa8c95c2a640a8ed16a2}


尝试等待信号量 


\begin{DoxyParams}{参数}
{\em void} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回\+S\+T\+A\+T\+U\+S\+\_\+\+O\+K,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
使信号量值减1,如果无资源可申请,则返回. 
\end{DoxyNote}
\hypertarget{class_semaphore_acbb526dfd6fa98bc2068652f5a61c661}{\index{Semaphore@{Semaphore}!wait@{wait}}
\index{wait@{wait}!Semaphore@{Semaphore}}
\subsubsection[{wait}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Semaphore\+::wait (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{class_semaphore_acbb526dfd6fa98bc2068652f5a61c661}


等待信号量 


\begin{DoxyParams}{参数}
{\em void} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回\+S\+T\+A\+T\+U\+S\+\_\+\+O\+K,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
使信号量值减1,如果无资源可申请,则阻塞. 
\end{DoxyNote}


该类的文档由以下文件生成\+:\begin{DoxyCompactItemize}
\item 
libemb/inc/\hyperlink{_semaphore_8h}{Semaphore.\+h}\item 
libemb/src/Semaphore.\+cpp\end{DoxyCompactItemize}
